package com.oscar.ehome.utils.dowload.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * Created by oscar
 * author: MengWanhe
 * date: On 2017/7/17
 */

public class VideoOpenHelper extends SQLiteOpenHelper {

    private final static String DB_NAME = "video.db";

    public VideoOpenHelper(Context context, String name, SQLiteDatabase.CursorFactory factory,
                           int version) {
        super(context, DB_NAME, factory, version);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        String createBookInfoSql = "CREATE TABLE [video_info] ("
                + "[video_id] VARCHAR,"
                + "[_id] INTEGER PRIMARY KEY AUTOINCREMENT,"
                + "[video_state] VARCHAR,"
                + "[video_downloadurl] VARCHAR,"
                + "[video_name] VARCHAR,"
                + "[video_path] VARCHAR,"
                + "[video_img] VARCHAR,"
                + "[video_title] VARCHAR,"
                + "[video_size] INTEGER NOT NULL DEFAULT (0),"
                + "[video_progress] INTEGER NOT NULL DEFAULT (0));";
        db.execSQL(createBookInfoSql);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        String dropVideoInfoSql = "drop table if exists video_info";
        db.execSQL(dropVideoInfoSql);
        onCreate(db);
    }
}
